# Contributor: Rasmus Thomsen <oss@cogitri.dev>
# Maintainer: Celeste <cielesti@protonmail.com>
pkgname=bloaty
pkgver=1.1
pkgrel=24
pkgdesc="Bloaty McBloatface: a size profiler for binaries"
options="!check" # no test suite
url="https://github.com/google/bloaty"
arch="all"
license="Apache-2.0"
makedepends="
	abseil-cpp-dev
	capstone-dev
	cmake
	protobuf-dev
	re2-dev
	samurai
	"
source="https://github.com/google/bloaty/releases/download/v$pkgver/bloaty-$pkgver.tar.bz2
	system-abseil.patch
	"

build() {
	if [ "$CBUILD" != "$CHOST" ]; then
		CMAKE_CROSSOPTS="-DCMAKE_SYSTEM_NAME=Linux -DCMAKE_HOST_SYSTEM_NAME=Linux"
	fi
	cmake -B build -G Ninja \
		-DCMAKE_BUILD_TYPE=MinSizeRel \
		-DCMAKE_INSTALL_PREFIX=/usr \
		-DBUILD_SHARED_LIBS=OFF \
		$CMAKE_CROSSOPTS
	cmake --build build
}

package() {
	DESTDIR="$pkgdir" cmake --install build

	rm -r "$pkgdir"/usr/lib
}

sha512sums="
142d0dd58fc0aadce3aee6e9260c6ed792a18cf5fe260c89051d51b9357c7527ba352c3d6c9e23a3494796fba3d88314b6ed8a3a76c6c0d111d4c509cae6b216  bloaty-1.1.tar.bz2
81e910f481c31622c71f8e2b24e35584819845e49321f195c1955bc60d9b4c04b878986dbd6fd703639deda478edc1ec25d52beae991fbd5fda92e4628619c6f  system-abseil.patch
"
